using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;

namespace mdv.wssSchemaExplorer.WSS
{
    public class wssMetadataController : IController
    {
        public wssMetadataController(wssMetadata metadata)
        {
            _actions = new ContextMenu();
            _metadata = metadata;
            if (null != _metadata.ContentTypes) _children.Add(new wssContentTypesController(_metadata.ContentTypes));
            else
                _actions.MenuItems.Add(new MenuItem("Add ContentTypes"));
            if (null != _metadata.Fields) _children.Add(new wssFieldsController(_metadata.Fields));
            else
                _actions.MenuItems.Add(new MenuItem("Add Fields"));
            if (null != _metadata.Forms) _children.Add(new wssFormsController(_metadata.Forms));
            else
                _actions.MenuItems.Add(new MenuItem("Add Forms"));
            if (null != _metadata.Views) _children.Add(new wssViewsController(_metadata.Views));
            else
                _actions.MenuItems.Add(new MenuItem("Add Views"));
        }
        public override string ToString()
        {
            return _metadata.ToString();
        }
        #region IController Members
        private List<IController> _children = new List<IController>();
        [Browsable(false)]
        public List<IController> Children
        {
            get { return _children; }
        }
        private ContextMenu _actions;
        [Browsable(false)]
        public ContextMenu Actions
        {
            get { return _actions; }
        }
        private wssMetadata _metadata = null;
        [Browsable(false)]
        public object Model
        {
            get { return _metadata; }
        }
        #endregion
    }
}